{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# 如何构建 Java版 jupyter环境\n",
    "\n",
    "在Java生态中构建类似Jupyter的交互式开发环境，可以通过以下两种主流方案实现，结合具体需求选择适配工具：\n",
    "\n",
    "### 方案一：使用 **Apache Zeppelin**（推荐）\n",
    "**核心优势**：专为多语言设计的交互式笔记本，支持Java、Scala、Python等，内置可视化模块。\n",
    "\n",
    "**操作步骤**：\n",
    "1. **下载与安装**\n",
    "   - 访问[Zeppelin官网](https://zeppelin.apache.org/)下载二进制包（如`zeppelin-0.12.0-bin-all.tgz`）。\n",
    "   - 解压后进入目录，执行`./bin/zeppelin-daemon.sh start`启动服务（默认端口8080）。\n",
    "\n",
    "2. **创建Java笔记本**\n",
    "   - 访问`http://localhost:8080`，新建Notebook并选择`%java`解释器。\n",
    "   - 示例代码：直接编写Java类并运行，支持实时输出结果。\n",
    "\n",
    "3. **功能扩展**\n",
    "   - 通过`%spark.java`解释器集成Spark（需配置Spark环境）。\n",
    "   - 使用`%sh`解释器混合Shell命令，增强数据处理灵活性。\n",
    "通过以下配置启动远程支持：\n",
    "`vim conf/zeppelin-site.xml`\n",
    "```xml\n",
    "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n",
    "<?xml-stylesheet type=\"text/xsl\" href=\"configuration.xsl\"?>\n",
    "<configuration>\n",
    "<property>\n",
    "  <name>zeppelin.server.addr</name>\n",
    "  <value>0.0.0.0</value>\n",
    "  <description>修改远程地址</description>\n",
    "</property>\n",
    "</configuration>\n",
    "\n",
    "```\n",
    "**适用场景**：大数据分析、多语言混合开发，需可视化支持的项目。\n",
    "\n",
    "### 方案二：基于 **JShell**（Java 9+内置工具）\n",
    "**核心优势**：轻量级、无需额外依赖，适合快速验证Java代码片段。\n",
    "\n",
    "**操作步骤**：\n",
    "1. **启动JShell**\n",
    "   - 终端执行`jshell`进入交互模式，直接输入代码（如`System.out.println(\"Hello\");`）即时执行。\n",
    "\n",
    "2. **集成到IDE**\n",
    "   - **IntelliJ IDEA**：安装`JShell Plugin`，在IDE内直接调用JShell。\n",
    "   - **VS Code**：通过`Java Extension Pack`中的“JShell终端”功能使用。\n",
    "\n",
    "3. **代码保存与复用**\n",
    "   - 使用`/save filename.jsh`保存会话，`/open filename.jsh`加载历史代码。\n",
    "\n",
    "**适用场景**：快速原型开发、代码片段测试，无需复杂环境配置。\n",
    "\n",
    "### 对比与建议\n",
    "| **维度**       | **Apache Zeppelin**                     | **JShell**                     |\n",
    "|----------------|-----------------------------------------|--------------------------------|\n",
    "| **依赖**       | 需单独安装，支持多语言                  | Java 9+内置，单语言           |\n",
    "| **可视化**     | 内置图表、表格展示                      | 无原生可视化，需依赖IDE       |\n",
    "| **复杂度**     | 适合数据分析项目                        | 适合简单代码验证              |\n",
    "| **扩展性**     | 可集成Spark、Flink等                    | 仅限Java标准库                |\n",
    "\n",
    "**推荐选择**：\n",
    "- 若需多语言支持或大数据处理，优先使用 **Zeppelin**。\n",
    "- 若仅需Java代码快速测试，**JShell** 更便捷。\n",
    "- 开发者可结合两者：用Zeppelin完成数据分析，用JShell调试核心逻辑。\n",
    "\n",
    "\n",
    "# 通过Conda配置Beaker扩展集支持Java\n",
    "\n",
    "该包需要python37\n",
    "\n",
    "```bash\n",
    "conda install -c beakerx beakerx_all\n",
    "```"
   ],
   "id": "b04c2d5b92392553"
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": [
    "# 环境变量\n",
    "\n",
    "## 1. JAVA_HOME\n",
    "\n",
    "jdk所在目录\n",
    "\n",
    "## 2. path\n",
    "\n",
    "```\n",
    "%JAVA_HOME%bin;\n",
    "```\n",
    "\n",
    "## 3. ClassPath\n",
    "\n",
    "```\n",
    ".;%JAVA_HOME%libdt.jar;%JAVA_HOME%liboos.jar\n",
    "```"
   ],
   "id": "61f4b9aafed78fb6"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
